< previous page page_153 next page >

Page 153
12181-0153a.gif
Figure 6.1.
Displaying the Declarations section of any module in the application in the
Code Editor.
The variable name True is really a constant with a value of -1. You could have written this line of code as follows:
frmNote.Visible = -1
Of course, the first version of the statement is much more readable, even if you knew the -1 meant True.
As you begin to add code to the event procedures in your application, you might find that you want several procedures to work with data in the same variable. As an example, you could store the value of a text box in a variable when a command button is clicked. However, suppose you declared that variable inside the procedure as follows:
Private Sub cmdSalesComplete()
Dim Sale_Amt As Single
    Sale_Amt = Csng(txtAmt_Total.Text)
   Any remaining code would go here
End Sub
Unfortunately, no other procedure would be capable of accessing this variable. Sale_Amt is considered local to just that procedure because you declared it inside the procedure itself. If you want other procedures to be capable of accessing the variable, you must move the declaration of it into the module's Declarations section.
As you might have discovered accidentally, there are several ways to declare variables in your application. If you just type variable names into your code as shown in the

 
< previous page page_153 next page >

If you like this book, buy it!